<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" ></meta>
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap-datetimepicker.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">
    <link rel="stylesheet" href="${frames}/css/picker.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/select2.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/beautify-time.css" type="text/css">
    <!--[if IE 8]>
    <link rel="stylesheet" href="${newframe}/css/base/IE8.css" type="text/css"/>
    <![endif]-->
    <style>
        .select2-container {
            width: 100% !important;
        }
    </style>
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script src="${frames}/laydate/laydate.dev.js"></script>
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>
    <script src="${newframe}/js/select2.full.zh.js"></script>
    <script>
        $(document).ready(function () {
            $('#myForm').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    depName:  {
                        validators: {
                            notEmpty: true,
                            remote: {
                                type: "post",
                                delay: 500,
                                url: '${URL_BASE_DEPARTMENT_VALIDATE_NAME}',
                                data: function (validator) {
                                    return {
                                        mobile: validator.getFieldElements('depName').val(),
                                        exception: '${entity.depName}'
                                    };
                                },
                                message: '该科室已存在'
                            }
                        }
                    },
                    depKind: {
                        validators: {
                            notEmpty: true
                        }
                    }
                }
            }).on('success.form.bv', function (e) {
                e.preventDefault();
                var _url="";
                if($("#id").val() == null || $("#id").val() == ''){
                    _url =  '${URL_BASE_DEPARTMENT_SAVE}';
                }else{
                    _url =  '${URL_BASE_DEPARTMENT_UPDATE}';
                }
                $.ajax({
                    url: _url,
                    type: 'post',
                    data: $('#myForm').serialize(),
                    async: false, //默认为true 异步
                    error: function () {
                        alert('error');
                    },
                    success: function (data) {
                        closeFrame();
                    }
                });
            });

        });

        //关闭并刷新
        function closeFrame() {
            window.parent.closeModal();
        }

    </script>
</head>
<body style="width: 98%">
<form id="myForm" class="form-horizontal" method="post">
    <input type="hidden" id="id" name="id" value="${entity.id}"/>
    <div class="clearfix">
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">科室名称</label>
            <div class="col-sm-8">
                <input type="text" id="depName" name="depName" class="form-control" value="${entity.depName}">
            </div>
        </div>
        <div class="form-group col-sm-6">
            <label class="col-sm-4 control-label">科室类别</label>
            <div class="col-sm-8">
                <select id="depKind" name="depKind" class="form-control">
                    <medi:configOpt name="depKind" key="${entity.depKind}"/>
                </select>
            </div>
        </div>
    </div>
    <div class="modal-footer" style="text-align: center ">
        <button type="button" class="btn btn-default" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">
            关闭
        </button>
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>
</body>
</html>